package org.example.sportdemo.service;

import org.example.sportdemo.entity.GroundCollection;
import org.example.sportdemo.entity.ProductCollection;
import org.example.sportdemo.mapper.GroundCollectionMapper;
import org.example.sportdemo.mapper.ProductCollectionMapper;
import org.example.sportdemo.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class ProductCollectionService {

    @Autowired
    private ProductCollectionMapper productCollectionMapper;

    public List<ProductCollection> selectAll(){
        return productCollectionMapper.selectAll();
    }

    public PageUtils queryPage(Map<String, Object> params) {
        //总数据
        List<ProductCollection> groundList = productCollectionMapper.selectAll();
        //总条数
        Integer totalCount = productCollectionMapper.selectCount();
        //当前页
        Integer currPage = Integer.valueOf((String) params.get("currPage"));
        //每页条数
        Integer pageSize = Integer.valueOf((String) params.get("pageSize"));
        return new PageUtils(totalCount,(Integer) pageSize,currPage,groundList);
    }

    public void addProductCollection(ProductCollection productCollection) {

        productCollectionMapper.addProductCollection(productCollection);

    }

    public ProductCollection selectById(Integer id) {
        return productCollectionMapper.selectById(id);
    }

    public void updateProductCollection(ProductCollection productCollection) {
        productCollectionMapper.updateProductCollection(productCollection);
    }

    public void deleteByIds(Integer[] ids) {
        productCollectionMapper.deleteByIds(ids);
    }
}
